<?php

/**
 * Global model for using in this application
 * @package Model
 * @author Chivorn VANN
 * @version 1.0
 */
if (!defined('BASEPATH'))
	exit('Permission Denied!');

class Mod_post extends CI_Model {
	function __construct() {
		parent::__construct();
	}
	// create new post
	function insert_newpost($img_url, $desc, $select_tag,$random_key,$post_url,$embedImg_url,$create_date){
	    $this->mod_globals->insert(PREFIX_TABLE."posts", array('use_tag_id' => $select_tag,'img_name' => $img_url,'embed_code'=> htmlentities($post_url),'description'=>$desc,'key_posts'=>$random_key,'embed_img'=>$embedImg_url,'created_date'=>$create_date));
	}
	function count_most_read(){
		$this -> db -> select('count(*) as t_records');
		$this -> db -> from(PREFIX_TABLE.'post_has_tags');
		$this -> db -> join(PREFIX_TABLE.'posts','use_post_id=post_id');
		$this -> db -> join(PREFIX_TABLE.'tags','tag_id = use_tag_id');
		$this -> db -> where(PREFIX_TABLE.'posts.status', 1);
		return $this -> db -> get();
		
	}
	function fbcomment(){
		$id = $this->uri->segment(4);
		$this -> db -> from(PREFIX_TABLE . 'posts');
		//$this->db->join('people', 'people.person_id = users.person_id');
		$this -> db -> where(PREFIX_TABLE . 'posts.post_id', $id);
		$query = $this -> db -> get();
	}
	function fblikebtn(){
		$id = $this->uri->segment(4);

		$this -> db -> from(PREFIX_TABLE . 'posts');
		//$this->db->join('people', 'people.person_id = users.person_id');
		$this -> db -> where(PREFIX_TABLE . 'posts.post_id', $id);
		$query = $this -> db -> get();
	}
}


